package com.hxgis.common.repository.cimiss;

import com.hxgis.cmiss.CimissBaseMapper;
import com.hxgis.cmiss.annotations.CInterfaceId;
import com.hxgis.cmiss.annotations.CMaterial;
import com.hxgis.common.utils.TimeUtil;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Component;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import static com.hxgis.common.utils.CollectionUtils.subArrays;

@Component
@CMaterial("SURF_CHN_MUL_DAY")
public class SurfChnMulDayMapper extends CimissBaseMapper {

    // 多线程执行
    @CInterfaceId("getSurfEleByTimeRangeAndStaID")
    public List<Map> getDataByTimeAndstationNoListThreads(String startTime, String endTime, List<String> stationNoList) {

        // 按站号的数量 来进行切分任务的数量
        List<Map<String,String>> paramsList = new ArrayList<Map<String,String>>();
        List<String>[] lists = subArrays(stationNoList, 500);
        for (List<String> list : lists) {
            Map<String,String> params = new HashMap<String, String>();
            params.put("timeRange","[" + startTime + "000000" + "," + endTime + "000000" + "]");
            params.put("staIds", StringUtils.join(list, ","));
            paramsList.add(params);
        }
        return getDataList(10,paramsList, Map.class,"Station_Id_C","PRE_Time_2020","PRE_Time_0808","Datetime");
    }


}
